import 'package:example/widget_demo/page_button_demo.dart';
import 'package:example/widget_demo/page_choose_demo.dart';
import 'package:example/widget_demo/page_count_down_demo.dart';
import 'package:example/widget_demo/page_dialog_demo.dart';
import 'package:example/widget_demo/page_floating_menu.dart';
import 'package:example/widget_demo/page_multi_line_input_demo.dart';
import 'package:example/widget_demo/page_search_demo.dart';
import 'package:example/widget_demo/page_single_input_demo.dart';
import 'package:example/widget_demo/page_single_show_demo.dart';
import 'package:example/widget_demo/page_tabbar_demo.dart';
import 'package:example/widget_demo/page_time_choose_demo.dart';
import 'package:example/widget_demo/page_title_demo.dart';
import 'package:example/widget_demo/page_toast_demo.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import '../page_time_axis_demo.dart';
import 'page_navigation_bar_demo.dart';

class DkWidgetDemo extends StatelessWidget {
  static const String routeName = '/page/dk_widget_demo';
  static const String name = "DkWidget Demo";

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      routes: routers,
      home: DkWidgetDemoPage('DkWidget Demo'),
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('zh', 'CH'),
      ],
    );
  }
}

class DkWidgetDemoPage extends StatelessWidget{
  final String title;
  DkWidgetDemoPage(this.title);
  final routerLists = routers.keys.toList();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: new Container(
        child: new ListView.builder(
          itemCount: routers.length,
          itemBuilder: (context, index) {
            return new InkWell(
              onTap: () {
                Navigator.of(context).pushNamed(routerLists[index]);
              },
              child: new Card(
                child: new Container(
                  alignment: Alignment.centerLeft,
                  margin: EdgeInsets.symmetric(horizontal: 10),
                  height: 50,
                  child: new Text(routerName[index]),
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}


Map<String, WidgetBuilder> routers = {
  SingleInputDemoPage.routeName: (context) {
    return SingleInputDemoPage();
  },
  MultiLineInputDemoPage.routeName: (context) {
    return MultiLineInputDemoPage();
  },
  TitleDemoPage.routeName: (context) {
    return TitleDemoPage();
  },
  SingleShowDemoPage.routeName: (context) {
    return SingleShowDemoPage();
  },
  ChooseDemoPage.routeName: (context) {
    return ChooseDemoPage();
  },
  NavigationBarDemoPage.routeName:(context){
    return NavigationBarDemoPage();
  },
  TabBarDemoPage.routeName:(context){
    return TabBarDemoPage();
  },
  CountDownDemoPage.routeName:(context){
    return CountDownDemoPage();
  },
  FloatingMenuDemoPage.routeName:(context){
    return FloatingMenuDemoPage();
  },
  PageTimeChooseDemoWidget.routeName:(context){
    return PageTimeChooseDemoWidget();
  },
  PageDialogDemoWidget.routeName:(context){
    return PageDialogDemoWidget();
  },
  PageSearchDemoWidget.routeName:(context){
    return PageSearchDemoWidget();
  },
  PageButtonDemoWidget.routeName:(context){
    return PageButtonDemoWidget();
  },
  PageTimeAxisWidget.routeName:(context){
    return PageTimeAxisWidget();
  },
  PageToastDemoWidget.routeName:(context){
    return PageToastDemoWidget();
  },
};

var routerName = [
  SingleInputDemoPage.name,
  MultiLineInputDemoPage.name,
  TitleDemoPage.name,
  SingleShowDemoPage.name,
  ChooseDemoPage.name,
  NavigationBarDemoPage.name,
  TabBarDemoPage.name,
  CountDownDemoPage.name,
  FloatingMenuDemoPage.name,
  PageTimeChooseDemoWidget.name,
  PageDialogDemoWidget.name,
  PageSearchDemoWidget.name,
  PageButtonDemoWidget.name,
  PageTimeAxisWidget.name,
  PageToastDemoWidget.name,
];
